Skip to main content

Data can be collected to supOS through various protocols, it can also be obtained through MQTT subscription, or even directly from supOS database.

Obtaining Data through MQTT Subscription

info

This method is only suitable for third parties who have experience in MQTT protocol.

  1. Log in to supOS, and then select UNS > Event Flow.
  2. Click New Event Flow, enter a name and click Save.
  3. Click the flow you just added, drag an mqtt in node, and enter the configurations.
    • supOS MQTT broker address: emqx:1883
    • Topic: The topic to obtain data from, for example, factory/workshop/order.
  1. Process the data obtained, or directly use an mqtt out node to transmit the data to the third party MQTT.
  1. Deploy the flow, and data will be pushed to the third party when the topic data changes.

Obtaining Data through API

info

This method is suitable for third parties who does not support MQTT and need event-driven data.

  1. Log in to supOS, and then select UNS > Event Flow.
  2. Click New Event Flow, enter a name and click Save.
  3. Click the flow you just added, drag an mqtt in node, and enter the configurations.
    • supOS MQTT broker address: emqx:1883
    • Topic: The topic to obtain data from, for example, factory/workshop/order.
  1. Drag a function node to the canvas, and write a script to format the data obtained according to third-party receiver API.
// parse payload if it's a string
if (typeof msg.payload === "string") {
msg.payload = JSON.parse(msg.payload);
}

// set headers
msg.headers = {
"Content-Type": "application/json"
};

return msg;
  1. Use an http request node to send the data to the third party through API.
  1. Deploy the flow, and data will be pushed to the third party when the topic data changes.

Obtaining Data Directly from supOS Database

info

This method is suitable for requests on history data.

  1. Log in to supOS, and then select UNS > Event Flow.
  2. Click New Event Flow, enter a name and click Save.
  3. Click the flow you just added, drag an inject node.
  4. Drag a postgres node to the canvas, and connect to supOS PostgreSQL database.
    • Connection
      • Host: postgresql
      • Port: 5432
      • Database: postgres
      • SSL: false
    • Security
      • User: postgres
      • Password: postgres
  1. Write SQL statements to query data from supOS database.
info

Get the table name from topic Details under Namespace.

SELECT * FROM _order_0baa755c15544f81a302;
  1. Add an http request or mqtt out node to transmit the queried data to the third party.